<%@page import="HumanM.PUser"%>
<%@page import="jdbc.DBOUser"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户登录处理页面</title>
</head>
<body>
  
  <%
  
    PUser user=new PUser();
   DBOUser DBu=new DBOUser();
   request.setCharacterEncoding("UTF-8");
   user.puser_name=request.getParameter("username");
   
   if(DBu.is_user_exist(user.puser_name))
   {
   user = DBu.Q_user_info(user.puser_name);
   user.puser_password=request.getParameter("password");
   
    if(user.puser_name=="")
    {
    	out.print("<script>alert('请输入用户名与密码！');window.location='User_login.jsp'</script>");
    }
    
    if(user.puser_locked==true)
    {
    	out.print("<script>alert('您的账号已被锁定，请申请解锁！');window.location='User_login.jsp'</script>");
    }
   
  if(DBu.is_user_true(user))
  {
	  session.setAttribute("user", user);
	  out.print("<script>alert('恭喜你！小辣鸡！登陆成功！');window.location='../main.jsp'</script>");
	 // response.sendRedirect("main.jsp");
  }else
  {
	  out.print("<script>alert('登陆失败，用户名或密码错误！请重新登陆！');window.location='User_login.jsp'</script>");
	  //response.sendRedirect("login.jsp");
  }
   }
   else{
	   
	   out.print("<script>alert('登陆失败，用户名不存在！请重新登陆！');window.location='User_login.jsp'</script>");
   }


%>
  


</body>
</html>